﻿@Html.DevExpress().GridView(
setting =>{
            setting.Name = "gvEditing";
            setting.KeyFieldName = "FID";
            setting.CallbackRouteValues = new { Controller = "FTPManage", Action = "FTPManageListPartial" };
            setting.Width = System.Web.UI.WebControls.Unit.Percentage(100);
            setting.SettingsPager.PageSize = ElingOA6_Admin_DSJCJ.Common.GlobalConstant.CONSTRING_PAGESIZE;
            setting.Columns.Add("FID", "编号").Visible = false; ;
           
            setting.Columns.Add(column =>
            {
                column.Caption = "操作";
                column.Width = System.Web.UI.WebControls.Unit.Pixel(60);
                column.SetDataItemTemplateContent(c =>
                {
                    if ((bool)ViewData["isall"] & DataBinder.Eval(c.DataItem, "FEmplNo").ToString() != ViewData["FEmplNo"].ToString())
                    {
                        @Html.DevExpress().HyperLink(s =>
                        {
                            s.Name = "uploadsee" + c.VisibleIndex; s.Properties.Text = "操作"; s.ToolTip = "操作";
                            s.NavigateUrl = Url.Content("~/Admin/FTPManage/UploadLook?Fid=" + DataBinder.Eval(c.DataItem, "FID").ToString() + "&deptno=" + DataBinder.Eval(c.DataItem, "FDeptNo").ToString());
                            s.Style.Add(HtmlTextWriterStyle.Cursor, "pointer");

                        }).GetHtml();

                        ViewContext.Writer.Write("  ");
                        @Html.DevExpress().HyperLink(s =>
                        {
                            s.Name = "download" + c.VisibleIndex; s.Properties.Text = "下载"; s.ToolTip = "下载";
                            s.NavigateUrl = Url.Content("~/Admin/FTPManage/DownloadSingle?fid=" + DataBinder.Eval(c.DataItem, "FID").ToString() );
                            s.Style.Add(HtmlTextWriterStyle.Cursor, "pointer");
                        }).GetHtml();
                    }
                    else
                    {
                        @Html.DevExpress().HyperLink(s =>
                        {
                            s.Name = "uploadlook" + c.VisibleIndex; s.Properties.Text = "修改"; s.ToolTip = "修改";
                            s.NavigateUrl = Url.Content("~/Admin/FTPManage/UploadLook?Fid=" + DataBinder.Eval(c.DataItem, "FID").ToString() + "&deptno=" + DataBinder.Eval(c.DataItem, "FDeptNo").ToString());
                            s.Style.Add(HtmlTextWriterStyle.Cursor, "pointer");
                            
                        }).GetHtml();

                        ViewContext.Writer.Write("  ");
                        
                        @Html.DevExpress().HyperLink(s =>
                        {
                            s.Name = "uploaddel" + c.VisibleIndex; s.Properties.Text = "删除"; s.ToolTip = "删除";
                            s.Properties.ClientSideEvents.Click = "function(){FidDel('" + DataBinder.Eval(c.DataItem, "FID") + "')}"; 
                            s.Style.Add(HtmlTextWriterStyle.Cursor, "pointer");

                        }).GetHtml();
                    }
                });
                column.Settings.AllowDragDrop = DefaultBoolean.False;
                column.Settings.AllowSort = DefaultBoolean.False;

                
            });

            setting.Columns.Add("FDeptName", "部门").Width = System.Web.UI.WebControls.Unit.Pixel(50);
            setting.Columns.Add("FLinkMan", "联系人").Width = System.Web.UI.WebControls.Unit.Pixel(70);
            setting.Columns.Add("FSubject", "上传主题");
            setting.Columns.Add("FCodeName", "上传类型").Width = System.Web.UI.WebControls.Unit.Pixel(65);
            setting.Columns.Add("FLinkTel", "联系电话").Width = System.Web.UI.WebControls.Unit.Pixel(95);
            // setting.Columns.Add("FAuditAmount", "补贴金额").CellStyle.HorizontalAlign = System.Web.UI.WebControls.HorizontalAlign.Right;
            setting.Columns.Add("FInputTimeStr", "上传日期").Width = System.Web.UI.WebControls.Unit.Pixel(85);
                

            setting.SettingsBehavior.AllowFocusedRow = true;
            setting.SettingsLoadingPanel.Text = "数据读取中...";
            //setting.TotalSummary.Add(DevExpress.Data.SummaryItemType.Count, "NSRBM").DisplayFormat = "总计:";
            //setting.TotalSummary.Add(DevExpress.Data.SummaryItemType.Sum, "FAuditAmount").DisplayFormat = "￥{0:f2}";

            //setting.GroupSummary.Add(DevExpress.Data.SummaryItemType.Sum, "FAuditAmount").DisplayFormat = "合计:￥{0}";

            setting.ClientSideEvents.BeginCallback = "function(s,e){OnBeginCallback(s,e)}";
            setting.ClientSideEvents.EndCallback = "function(){}";
            //  setting.Columns["FAuditAmount"].FooterCellStyle.HorizontalAlign = System.Web.UI.WebControls.HorizontalAlign.Right;
       
            setting.CommandColumn.Visible = true;
            setting.CommandColumn.Width = System.Web.UI.WebControls.Unit.Pixel(5);
            setting.CommandColumn.ShowSelectCheckbox = true;
            setting.CommandColumn.SetHeaderTemplateContent(c =>
            {


                @Html.DevExpress().CheckBox(settingsCheckBox =>
                {
                    settingsCheckBox.Name = "cbSelectAll";
                    settingsCheckBox.Properties.ClientSideEvents.CheckedChanged = string.Format("function(s, e) {{ if(s.GetChecked()) {0}.SelectAllRowsOnPage(); else {0}.UnselectAllRowsOnPage(); }}", setting.Name);

                    if (c.Grid.VisibleRowCount == 0)
                    {
                        settingsCheckBox.Enabled = false;

                    }
                    else
                    {
                        settingsCheckBox.Checked = c.Grid.VisibleRowCount == c.Grid.Selection.Count;
                    }


                }).Render();
            });

            setting.DataBinding = (sender, e) =>
            {
                ASPxGridView grid = (ASPxGridView)sender;
                for (int i = 0; i < grid.AllColumns.Count; i++)
                {
                    if (grid.AllColumns[i].HeaderStyle.HorizontalAlign == System.Web.UI.WebControls.HorizontalAlign.NotSet)
                    {
                        grid.AllColumns[i].HeaderStyle.HorizontalAlign = System.Web.UI.WebControls.HorizontalAlign.Center;
                    }
                }

            };
            setting.PageIndexChanged = (sender, e) =>
            {
                ASPxGridView grid = (ASPxGridView)sender;
                grid.Selection.UnselectAll();
                Session["pi"] = grid.PageIndex;
            };
            setting.DataBound = (sender, e) =>
            {
                ASPxGridView grid = (ASPxGridView)sender;
                if (ViewData["pageIndex"] != null && ViewData["pageIndex"].ToString() != "")
                {
                    if (grid.PageCount < int.Parse(ViewData["pageIndex"].ToString()))
                    {
                        grid.PageIndex = 0;
                    }
                    else
                    {
                        grid.PageIndex = int.Parse(ViewData["pageIndex"].ToString());
                    }
                }
            };
}).Bind(Model).GetHtml()